<?php
namespace Core\Libs\Extend;

class Object {

	
}

class Config {

	private static $config = array();

	final private static function &validarGravacao($checarTipo, $tipo, $parametro, $retorno = TRUE) {

		if(empty($tipo)) {

			$tipo = NULL;
		}

		if($checarTipo === 'publico' || empty($checarTipo)) {}

		elseif($checarTipo === 'protegido' && $tipo !== TRUE) {

			echo 'Conteúdo de acesso protegido, para realizar a sobreescrita pelos métodos: \Core\Uses\Gravar(...) ou \Core\Libs\Extend\Gravar(...) o terceiro parâmetro deve ser TRUE - Checado em: ['.$parametro.'].';
			exit();
		}

		elseif($checarTipo === 'privado') {

			echo 'Conteúdo de acesso privado, impossibilitando sua sobreescrita pelos métodos: \Core\Uses\Gravar(...) ou \Core\Libs\Extend\Gravar(...) - Checado em: ['.$parametro.'].';
			exit();
		}

		if($retorno) {

			return $tipo;
		}
	}

	final public static function gravar($parametro, $valor, $tipo = 'publico', $array = TRUE) {

		$parametro = mb_strtolower(&$parametro);
		$string = '';

		if($array) {

			if(strpos($parametro, '.')) {

				$arrayAux =& explode('.', $parametro);
				$count =& count(&$arrayAux);

				if(count(array_intersect(array('_value', '_type'), &$arrayAux)) > 0) {

					echo 'Paranetros [_value, _type] são restritos ao uso do framework, String passada: [ '.$parametro.' ].';
					exit();
				}

				for($i=0; $i < $count; $i++) {

					($i) ? $string .= '[\''.$arrayAux[$i].'\']' : $string .= 'self::$config[\''.$arrayAux[$i].'\']';
				}

				$checarTipo = 'publico';
				eval('(isset('.$string.'[\'_type\'])) ? $checarTipo = '.$string.'[\'_type\'] : $checarTipo = NULL;');
				$tipo =& self::validarGravacao($checarTipo, $tipo, $parametro);
				$string = $string.'[\'_value\'] = $valor; '.$string.'[\'_type\'] = $tipo;';
				eval($string);
			}

			else {

				$tipo =& self::validarGravacao(self::$config[$parametro]['_type'], $tipo, $parametro);
				self::$config[$parametro]['_value'] = $valor;
				self::$config[$parametro]['_type'] = $tipo;
			}
		}

		else {

			$tipo =& self::validarGravacao(self::$config[$parametro]['_type'], $tipo, $parametro);
			self::$config[$parametro]['_value'] = $valor;
			self::$config[$parametro]['_type'] = $tipo;
		}
	}

	final public static function ler($parametro, $array = TRUE, $retorno = 'valor') {

		$parametro = mb_strtolower(&$parametro);
		$arrayString = '';

		if($array) {

			if(strpos($parametro, '.')) {

				$arrayAux =& explode('.', $parametro);
				$count =& count(&$arrayAux);
				$value = NULL;

				for($i=0; $i < $count; $i++) {

					($i) ? $arrayString .= '[\''.$arrayAux[$i].'\']' : $arrayString .= 'self::$config[\''.$arrayAux[$i].'\']';
				}

				if($retorno === 'valor') {

					$arrayString = '(isset('.$arrayString.'[\'_value\'])) ? $parametro = '.$arrayString.'[\'_value\'] : $parametro = NULL;';
				}

				elseif($retorno === 'array') {

					$arrayString = '(isset('.$arrayString.')) ? $parametro = '.$arrayString.' : $parametro = NULL;';
				}

				else {

					return NULL;
				}

				eval($arrayString);

				if($parametro === NULL) {

					$parametro = FALSE;
				}

				return $parametro;
			}

			else {

				if($retorno === 'valor') {

					$parametro = self::$config[$parametro]['_value'];
				}

				elseif($retorno === 'array') {

					$parametro = self::$config[$parametro];
				}

				return $parametro;
			}
		}

		else {

			if($retorno === 'valor') {

				$parametro = self::$config[$parametro]['_value'];
			}

			elseif($retorno === 'array') {

				$parametro = self::$config[$parametro];
			}

			return $parametro;
		}
	}

	final public static function getNamespace($nameSpace, $type = 0) {

		($type === 0) ? $expression = '/(?<=\\|\\\|\\\\|\-)[a-z]{1,1}/' : $expression = '/^[a-z]|(?<=\-|\.|\_|\ )[a-z]{1,1}/';

		return str_replace('-', '', preg_replace_callback(&$expression, create_function('$match', 'return strtoupper($match[0]);'), &$nameSpace));
	}
/*
	final public static function getTableName($string = NULL) {

		return mb_strtolower(preg_replace('/.([A-Z]+)/', '_\1', &$string));
	}*/
	final public static function getTableName($string = NULL) {
	
		$stringOut;
		if(preg_match('/((?:^|[A-Z])[a-z]+)/',$string))
		{
			preg_match_all('/((?:^|[A-Z])[a-z]+)/',$string,$matches);
			if(count($matches[0]) > 1)
			{
				for($i = 0; $i < count($matches[0]); $i++)
				{
					
					$stringOut .=  $matches[0][$i];
					if(count($matches[0])-1 != $i)
					{
						$stringOut .= "_";
					}
				}
			}
			else
			{
				$stringOut = $string;
			} 
		}
		$stringOut = \Core\Libs\Inflexao\Inflexao::_singularizarOuPluralizar($stringOut,'plural', 'caixaBaixa', 0);
		return $stringOut;
	}
	
	final public static function getActivePlugins($adicionarAoNameSpace = NULL) {

		$arrayPlugins = array();
		$arrayPluginsAtivos = array();
		$arrayPlugins = \Core\Uses\Ler('Plugin', TRUE, 'array');

		if(!is_array(&$arrayPlugins)) {

			$arrayPlugins = array();
		}

		$adicionarAoNameSpace =& str_replace('.', '\\', &$adicionarAoNameSpace);

		foreach($arrayPlugins as $plugin => $arrayPlugin) {

			if($arrayPlugin['status']['_value'] === TRUE) {

				$arrayPluginsAtivos[] = self::getNamespace('\\Plugins\\'.$plugin.'\\'.$adicionarAoNameSpace);
			}
		}

		if(!count($arrayPluginsAtivos)) {

			return FALSE;
		}

		return $arrayPluginsAtivos;
	}

	final public static function getActiveModules($nomeDaAplicacao = NULL, $adicionarAoNameSpace = NULL) {

		$arrayModules = array();
		$arrayPlugins = array();
		$arrayModulesAtivos = array();
		$recursivo = FALSE;

		if(!empty($nomeDaAplicacao)) {

			$arrayModules = \Core\Uses\Ler($nomeDaAplicacao.'.Module', TRUE, 'array');
			$recursivo = FALSE;
		}

		else {

			$arrayPlugins = \Core\Uses\Ler('Plugin', TRUE, 'array');
			$recursivo = TRUE;
		}

		$nomeDaAplicacao =& str_replace('.', '\\', preg_replace('/^(plugin|package)/i', '\1s', &$nomeDaAplicacao));

		if(!$recursivo) {

			if(!is_array(&$arrayModules)) {

				$arrayModules = array();
			}

			foreach($arrayModules as $module => $arrayModule) {

				if($arrayModule['status']['_value'] === TRUE) {

					$arrayModulesAtivos[] = self::getNamespace('\\'.$nomeDaAplicacao.'\\Extensions\\Modules\\'.$module.'\\'.$adicionarAoNameSpace);
				}
			}
		}

		else {

			foreach($arrayPlugins as $plugin => $arrayPlugin) {

				if(!is_array(&$arrayPlugin['module'])) {

					$arrayPlugin['module'] = array();
				}

				if($arrayPlugin['status']['_value'] === TRUE) {

					foreach($arrayPlugin['module'] as $module => $arrayModule) {

						if($arrayModule['status']['_value'] === TRUE) {

							$arrayModulesAtivos[] = self::getNamespace('\\Plugins\\'.$plugin.'\\Extensions\\Modules\\'.$module.'\\'.$adicionarAoNameSpace);
						}
					}
				}
			}
		}

		unset($arrayPlugins, $arrayPlugin, $arrayModule, $arrayModules, $nomeDaAplicacao, $module);

		if(!count($arrayModulesAtivos)) {

			return FALSE;
		}

		return $arrayModulesAtivos;
	}

	final public static function getActiveModulesOfPlugins($arrayApps = array(), $adicionarAoNameSpace = NULL) {

		if(is_array(&$arrayApps)) {

			$match = array();
			$arraySlice = $arrayApps;
			$countTemp = 0;

			foreach($arrayApps as $i => $app) {

				//preg_match('/^.plugins.[a-z0-9\_]+./i', $app, &$match);
				$app = self::getActiveModules(preg_replace('/^.plugins./i', 'plugin.', substr($app, 0, -1), 1), &$adicionarAoNameSpace);

				if($app !== FALSE) {

					$arraySlice[0] =& array_slice(&$arraySlice, 0, $i + $countTemp + 1);					
					$arraySlice[1] =& array_slice(&$arraySlice, $i + $countTemp + 1);
					$arraySlice[0] =& array_merge(&$arraySlice[0], &$app);
					$countTemp = count(&$arraySlice[0]) - 1;
					$arraySlice =& array_merge(&$arraySlice[0], &$arraySlice[1]);		
				}
			}

			if(count($arraySlice) > 0) {

				$arrayApps =& $arraySlice;
				unset($arraySlice);
			}

			return $arrayApps;
		}

		return FALSE;
	}

	final public static function getPluginsAndModulesActives($nomeDaAplicacao = NULL, $adicionarAoNameSpace = NULL) {

		$array['plugins'] =& self::getActivePlugins(&$adicionarAoNameSpace);
		$array['modules'] =& self::getActiveModules(&$nomeDaAplicacao, &$adicionarAoNameSpace);

		if($array['plugins'] && $array['modules']) {

			$array['plugins'] = self::getActiveModulesOfPlugins($array['plugins'], &$adicionarAoNameSpace);
			return $array;
		}

		elseif($array['plugins'] && !$array['modules']) {

			$array['plugins'] =& self::getActiveModulesOfPlugins($array['plugins'], &$adicionarAoNameSpace);
			unset($array['modules']);
			return $array;
		}

		elseif(!$array['plugins'] && $array['modules']) {

			unset($array['plugins']);
			return $array;
		}

		return FALSE;
	}
}

class Directory {

	private static $_arrayConfigExtensions = array();

	final public static function initDirectories($app, $access = 'publico') {

		$_nameDirLibs = 'libs';
		$_nameDirControllers = 'controllers';
		$_nameDirModels = 'models';
		$_nameDirViews = 'views';
		$_nameDirFolderViews = 'folder-views';
		$_nameDirDesign = 'design';
		$_nameDirHelpers = 'helpers';
		$_nameDirExtensions = 'extensions';
		$_nameDirModules = 'modules';
		$_nameDirPlugins = 'plugins';
		$_nameDirPackages = 'packages';
		$_nameDirComponents = 'components';
		$_nameDirBehaviors = 'behaviors';
		$_nameDirDataSources = 'datasouces';
		$_nameDirElements = 'elements';
		$_nameDirPages = 'pages';
		$_nameDirPrototypes = 'prototypes';
		$_nameDirLayouts = 'layouts';
		$_nameDirJs = 'js';
		$_nameDirImg = 'img';
		$_nameDirFiles = 'files';
		$_nameDirCss = 'css';
		$_nameDirTemporary = 'temporary';
		$_nameDirCache = 'cache';

		$app =& mb_strtolower(&$app);
		$dirCore =& self::getRootDirectory($app, TRUE);
		preg_match('/^[a-z0-9\_\-]+/i', $app, $match);
		$appType = $match[0];
		$path = '';
		$pathWebroot = '';
		$pathModules = '';
		$regularExpression = '';
		$isPluginOrPackage = FALSE;

		if($appType === 'plugins' || $appType === 'packages') {

			preg_match('/^([a-z0-9\_\-]+)\.([a-z0-9\_\-]+)(?:\.extensions\.(modules)\.([a-z0-9\_\-]+))?/i', $app, $match);
			$pathRoot = EXTENSIONS . $match[1] . DS . $match[2] . DS;
			$path = $pathRoot . $dirCore . DS;
			$isPluginOrPackage = TRUE;
		}

		elseif($appType === 'core' || $appType === 'jabez' || $appType === 'jabez-php') {

			preg_match('/^([a-z0-9\_\-]+)(?:\.(extensions)\.(modules)\.([a-z0-9\_\-]+))?/i', $app, $match);
			$pathRoot = JABEZ;
			$path = JABEZ_CORE;
		}

		else {

			$pathRoot = PROJECT;
			$path = PROJECT_CORE;
		}

		\Core\Uses\Gravar($app.'.dir.temporary.default.name', $_nameDirTemporary, $access);
		\Core\Uses\Gravar($app.'.dir.temporary.cache.default.name', $_nameDirCache, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.libs.default.name', $_nameDirLibs, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.controllers.default.name', $_nameDirControllers, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.views.default.name', $_nameDirViews, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.default.name', $_nameDirExtensions, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.modules.default.name', $_nameDirModules, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.models.default.name', $_nameDirModels, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.models.behaviors.default.name', $_nameDirBehaviors, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.models.data-sources.default.name', $_nameDirDataSources, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.controllers.components.default.name', $_nameDirComponents, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.views.helpers.default.name', $_nameDirHelpers, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.design.views.default.name', $_nameDirViews, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.design.elements.default.name', $_nameDirElements, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.design.pages.default.name', $_nameDirPages, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.design.prototypes.default.name', $_nameDirPrototypes, $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.design.layouts.default.name', $_nameDirLayouts, $access);
		\Core\Uses\Gravar($app.'.dir.www.css.default.name', $_nameDirCss, $access);
		\Core\Uses\Gravar($app.'.dir.www.js.default.name', $_nameDirJs, $access);
		\Core\Uses\Gravar($app.'.dir.www.img.default.name', $_nameDirImg, $access);
		\Core\Uses\Gravar($app.'.dir.www.files.default.name', $_nameDirFiles, $access);
		\Core\Uses\Gravar($app.'.dir.www.default.name', WWW_ROOT, $access);

		$_nameDirTemporary = \Core\Uses\Ler($app.'.dir.temporary.default.name');
		$_nameDirCache = \Core\Uses\Ler($app.'.dir.temporary.cache.default.name');
		$_nameDirLibs = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.libs.default.name');
		$_nameDirControllers = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.controllers.default.name');
		$_nameDirViews = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.views.default.name');
		$_nameDirExtensions = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.extensions.default.name');
		$_nameDirModules = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.extensions.modules.default.name');
		$_nameDirModels = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.extensions.models.default.name');
		$_nameDirBehaviors = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.extensions.models.behaviors.default.name');
		$_nameDirDataSources = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.extensions.models.data-sources.default.name');
		$_nameDirComponents = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.extensions.controllers.components.default.name');
		$_nameDirHelpers = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.extensions.views.helpers.default.name');
		$_nameDirViews = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.design.views.default.name');
		$_nameDirElements = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.design.elements.default.name');
		$_nameDirPages = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.design.pages.default.name');
		$_nameDirPrototypes = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.design.prototypes.default.name');
		$_nameDirLayouts = \Core\Uses\Ler($app.'.dir.'.$dirCore.'.design.layouts.default.name');
		$_nameDirCss = \Core\Uses\Ler($app.'.dir.www.css.default.name');
		$_nameDirJs = \Core\Uses\Ler($app.'.dir.www.js.default.name');
		$_nameDirImg = \Core\Uses\Ler($app.'.dir.www.img.default.name');
		$_nameDirFiles = \Core\Uses\Ler($app.'.dir.www.files.default.name');
		//\Core\Uses\Ler($app.'.dir.www.default.name', WWW_ROOT, $access);

		if(isset($match[3]) && $match[3] === 'modules') {

			$pathModules = $_nameDirExtensions . DS . $_nameDirModules . DS;
			$pathRoot = $path . $pathModules;

			if(!empty($match[4])) {

				$pathModules .= $match[4] . DS . $dirCore . DS;
				$pathRoot .= $match[4] . DS;
			}
		}

		$_arrayDefaultExtensions =& self::getDefaultExtensions('array');

		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.libs.default', array('path' => $path . $pathModules . $_nameDirLibs . DS, 'contents' => $_arrayDefaultExtensions['lib']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.controllers.default', array('path' => $path . $pathModules . $_nameDirControllers . DS, 'contents' => $_arrayDefaultExtensions['controller']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.views.default', array('path' => $path . $pathModules . $_nameDirViews . DS, 'contents' => $_arrayDefaultExtensions['view']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.default', array('path' => $path . $_nameDirExtensions . DS, 'contents' => $_arrayDefaultExtensions['extension']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.models.default', array('path' => $path . $pathModules . $_nameDirExtensions . DS . $_nameDirModels . DS, 'contents' => $_arrayDefaultExtensions['model']['contents'], 'extend' => TRUE), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.models.behaviors.default', array('path' => $path . $pathModules . $_nameDirExtensions . DS . $_nameDirModels . DS . $_nameDirBehaviors . DS, 'contents' => $_arrayDefaultExtensions['behavior']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.models.data-sources.default', array('path' => $path . $pathModules . $_nameDirExtensions . DS . $_nameDirModels . DS . $_nameDirDataSources . DS, 'contents' => $_arrayDefaultExtensions['datasource']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.views.helpers.default', array('path' => $path . $pathModules . $_nameDirExtensions . DS . $_nameDirViews . DS . $_nameDirHelpers . DS, 'contents' => $_arrayDefaultExtensions['helper']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.modules.default', array('path' => $path . $pathModules . $_nameDirExtensions . DS . $_nameDirModules . DS, 'contents' => FALSE), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.extensions.controllers.components.default', array('path' => $path . $pathModules . $_nameDirExtensions . DS . $_nameDirControllers . DS. $_nameDirComponents . DS, 'contents' => $_arrayDefaultExtensions['component']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.design.elements.default', array('path' => $path . $pathModules . $_nameDirDesign . DS . $_nameDirElements . DS, 'contents' => $_arrayDefaultExtensions['element']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.design.pages.default', array('path' => $path . $pathModules . $_nameDirDesign . DS . $_nameDirPages . DS, 'contents' => $_arrayDefaultExtensions['page']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.design.prototypes.default', array('path' => $path . $pathModules . $_nameDirDesign . DS . $_nameDirPrototypes . DS, 'contents' => $_arrayDefaultExtensions['prototype']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.design.layouts.default', array('path' => $path . $pathModules . $_nameDirDesign . DS . $_nameDirLayouts . DS, 'contents' => $_arrayDefaultExtensions['layout']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.'.$dirCore.'.design.views.default', array('path' => $path . $pathModules . $_nameDirDesign . DS . $_nameDirViews . DS, 'contents' => $_arrayDefaultExtensions['view']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.www.css.default', array('path' => $pathRoot . WWW_ROOT . DS . $_nameDirCss . DS, 'contents' => $_arrayDefaultExtensions['css']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.www.js.default', array('path' => $pathRoot . WWW_ROOT . DS . $_nameDirJs . DS, 'contents' => $_arrayDefaultExtensions['js']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.www.img.default', array('path' => $pathRoot . WWW_ROOT . DS . $_nameDirImg . DS, 'contents' => $_arrayDefaultExtensions['img']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.www.files.default', array('path' => $pathRoot . WWW_ROOT . DS . $_nameDirFiles . DS, 'contents' => $_arrayDefaultExtensions['file']['contents']), $access);
		\Core\Uses\Gravar($app.'.dir.temporary.cache.default', array('path' => $pathRoot . $_nameDirTemporary . DS . $_nameDirCache . DS, 'contents' => $_arrayDefaultExtensions['file']['contents']), $access);
	}

	final public static function getRootDirectory($app, $useDefault = FALSE) {

		$app =& mb_strtolower(&$app);

		if($app === 'core') {

			return DIR_JABEZ_CORE;
		}

		elseif($app === ACTIVE_PROJECT) {

			return DIR_CORE_PROJECT;
		}

		$dir = \Core\Uses\Ler($app.'.dir.core.default.name');

		if($useDefault && empty($dir)) {

			return DIR_JABEZ_CORE;
		}

		elseif(!$useDefault && !empty($dir)) {

			return $dir;
		}

		elseif(empty($dir)) {

			return DIR_JABEZ_CORE;
		}

		return \Core\Uses\Ler($app.'.dir.core.default.name');
	}

	final public static function &getDefaultExtensions($retorno = NULL) {

		if(empty(self::$_arrayConfigExtensions)) {

			self::$_arrayConfigExtensions = array(

				'lib' => array(

								'contents' => array(
													'class' => array('file' => '.lib', 'ext' => '.php', 'type' => '.cls', 'core' => FALSE),
													'function' => array('file' => '.lib', 'ext' => '.php', 'type' => '.fnc', 'core' => FALSE),
													'interface' => array('file' => '.lib', 'ext' => '.php', 'type' => '.int', 'core' => FALSE),
													'constant' => array('file' => '.lib', 'ext' => '.php', 'type' => '.con', 'core' => FALSE),
													'initializer' => array('file' => '.lib', 'ext' => '.php', 'type' => '.ini', 'core' => FALSE),
													'core' => array(),
													'default' => array('file' => '.lib', 'ext' => '.php', 'type' => '.cls', 'core' => FALSE))),

				'model' => array(

								'contents' => array(
													'class' => array('file' => '.model', 'ext' => '.php', 'type' => '.cls', 'core' => FALSE),
													'function' => array('file' => '.model', 'ext' => '.php', 'type' => '.fnc', 'core' => FALSE),
													'interface' => array('file' => '.model', 'ext' => '.php', 'type' => '.int', 'core' => FALSE),
													'constant' => array('file' => '.model', 'ext' => '.php', 'type' => '.con', 'core' => FALSE),
													'initializer' => array('file' => '.model', 'ext' => '.php', 'type' => '.ini', 'core' => FALSE),
													'core' => array(),
													'default' => array('file' => '.model', 'ext' => '.php', 'type' => '.cls', 'core' => FALSE))),

				'controller' => array(

									'contents' => array(
														'class' => array('file' => '.controller', 'ext' => '.php', 'type' => '.cls', 'core' => FALSE),
														'function' => array('file' => '.controller', 'ext' => '.php', 'type' => '.fnc', 'core' => FALSE),
														'interface' => array('file' => '.controller', 'ext' => '.php', 'type' => '.int', 'core' => FALSE),
														'constant' => array('file' => '.controller', 'ext' => '.php', 'type' => '.con', 'core' => FALSE),
														'initializer' => array('file' => '.controller', 'ext' => '.php', 'type' => '.ini', 'core' => FALSE),
														'core' => array(),
														'default' => array('file' => '.controller', 'ext' => '.php', 'type' => '.cls', 'core' => FALSE))),

				'view' => array(

								'contents' => array(
													'class' => array('file' => '.view', 'type' => '.cls', 'ext' => '.php', 'core' => FALSE),
													'view' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
													'default' => array('file' => '.view', 'type' => '.cls', 'ext' => '.php', 'core' => FALSE),
													'xml' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.xml', 'core' => FALSE),
													'json' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.json', 'core' => FALSE),
													'core' => array())),

				'design' => array(

								'contents' => array(
													'view' => array(
																	'default' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
																	'javascript' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.js', 'core' => FALSE),
																	'js' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.js', 'core' => FALSE),
																	'json' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.json', 'core' => FALSE),
																	'css' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.css', 'core' => FALSE),
																	'html' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
																	'text' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.txt', 'core' => FALSE),
																	'txt' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.txt', 'core' => FALSE),
																	'xhtml' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
																	'xhtml-mobile' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
																	'xml' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.xml', 'core' => FALSE),
																	'rss' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.rss', 'core' => FALSE),
																	'atom' => array('file' => '.view', 'type' => '.jtp', 'ext' => '.atom', 'core' => FALSE)),

													'layout' => array(
																	'default' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
																	'javascript' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.js', 'core' => FALSE),
																	'js' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.js', 'core' => FALSE),
																	'json' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.json', 'core' => FALSE),
																	'css' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.css', 'core' => FALSE),
																	'html' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
																	'text' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.txt', 'core' => FALSE),
																	'txt' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.txt', 'core' => FALSE),
																	'xhtml' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
																	'xhtml-mobile' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
																	'xml' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.xml', 'core' => FALSE),
																	'rss' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.rss', 'core' => FALSE),
																	'atom' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.atom', 'core' => FALSE),
																	'core' => array())
													)
								),

				'component' => array(

									'contents' => array(
														'class' => array('file' => '.component', 'ext' => '.php', 'type' => '.cls', 'core' => FALSE),
														'function' => array('file' => '.component', 'ext' => '.php', 'type' => '.fnc', 'core' => FALSE),
														'interface' => array('file' => '.component', 'ext' => '.php', 'type' => '.int', 'core' => FALSE),
														'constant' => array('file' => '.component', 'ext' => '.php', 'type' => '.con', 'core' => FALSE),
														'initializer' => array('file' => '.component', 'ext' => '.php', 'type' => '.ini', 'core' => FALSE),
														'core' => array(),
														'default' => array('file' => '.component', 'ext' => '.php', 'type' => '.cls', 'core' => FALSE))),

				'behavior' => array(

									'contents' => array(
														'class' => array('file' => '.behavior', 'ext' => '.php', 'type' => '.cls', 'core' => FALSE),
														'function' => array('file' => '.behavior', 'ext' => '.php', 'type' => '.fnc', 'core' => FALSE),
														'interface' => array('file' => '.behavior', 'ext' => '.php', 'type' => '.int', 'core' => FALSE),
														'constant' => array('file' => '.behavior', 'ext' => '.php', 'type' => '.con', 'core' => FALSE),
														'initializer' => array('file' => '.behavior', 'ext' => '.php', 'type' => '.ini', 'core' => FALSE),
														'core' => array(),
														'default' => array('file' => '.behavior', 'ext' => '.php', 'type' => '.cls','core' => FALSE))),

				'datasource' => array(

									'contents' => array(
														'class' => array('file' => '.datasource', 'ext' => '.php', 'type' => '.cls', 'core' => TRUE),
														'function' => array('file' => '.datasource', 'ext' => '.php', 'type' => '.fnc', 'core' => FALSE),
														'interface' => array('file' => '.datasource', 'ext' => '.php', 'type' => '.int', 'core' => FALSE),
														'constant' => array('file' => '.datasource', 'ext' => '.php', 'type' => '.con', 'core' => FALSE),
														'initializer' => array('file' => '.datasource', 'ext' => '.php', 'type' => '.ini', 'core' => FALSE),
														'core' => array(),
														'default' => array('file' => '.datasource', 'ext' => '.php', 'type' => '.cls', 'core' => FALSE))),

				'page' => array(

								'contents' => array(
													'default' => array('file' => '.page', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
													'core' => array())),

				'layout' => array(

									'contents' => array(
														'default' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
														'json' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.json', 'core' => FALSE),
														'xml' => array('file' => '.layout', 'type' => '.jtp', 'ext' => '.xml', 'core' => FALSE),
														'core' => array())),

				'element' => array(

								'contents' => array(
													'default' => array('file' => '.element', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
													'core' => array())),

				'helper' => array(

								'contents' => array(
													'default' => array('file' => '.helper', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
													'core' => array())),

				'prototype' => array(

									'contents' => array(
														'default' => array('file' => '.prototype', 'type' => '.jtp', 'ext' => '.php', 'core' => FALSE),
														'core' => array())),

				'css' => array(

								'contents' => array(
													'default' => array('file' => '', 'type' => '', 'ext' => '.css', 'core' => FALSE),
													'css' => array('file' => '', 'type' => '', 'ext' => '.css', 'core' => FALSE))),

				'js' => array(

								'contents' => array(
													'default' => array('file' => '', 'type' => '', 'ext' => '.js', 'core' => FALSE),
													'js' => array('file' => '', 'type' => '', 'ext' => '.js', 'core' => FALSE))),
			
				'img' => array(

								'contents' => array(
													'default' => array('file' => '', 'type' => '', 'ext' => '.jpg', 'core' => FALSE),
													'jpg' => array('file' => '', 'type' => '', 'ext' => '.jpg', 'core' => FALSE),
													'jpeg' => array('file' => '', 'type' => '', 'ext' => '.jpg', 'core' => FALSE),
													'png' => array('file' => '', 'type' => '', 'ext' => '.png', 'core' => FALSE),
													'gif' => array('file' => '', 'type' => '', 'ext' => '.gif', 'core' => FALSE),
													'bmp' => array('file' => '', 'type' => '', 'ext' => '.bmp', 'core' => FALSE))),

				'html' => array(

								'contents' => array(
													'default' => array('file' => '', 'type' => '', 'ext' => '.html', 'core' => FALSE),
													'html' => array('file' => '', 'type' => '', 'ext' => '.html', 'core' => FALSE))),

				'extension' => array(

									'contents' => array()),

				'file' => array(

								'contents' => array())
			);
		}

		if($retorno === 'array') {

			$array =& self::$_arrayConfigExtensions;
			return $array;
		}
	}
}
?>